package com.homework.work02;

import java.util.Scanner;

public class Work02_04 {
    public static void main(String[] args) {
        Scanner sc = new  Scanner(System.in);
        System.out.println("请输入一个正整数: ");
        int n = sc.nextInt();
        isPrime(n);
    }
    public static boolean isPrime(int n){
        //n<=3时，质数有2和3
        if (n <= 3) {
            return n > 1;
        }
        //当n>3时，质数无法被比它小的数整除
        for(int i = 2; i < n; i++){
            if (n % i == 0) {
                System.out.println("不是质数");
                return false;
            }
        }
        System.out.println("是质数");
        return true;
    }
}
